﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B121B {
    /// <summary>
    /// The car class
    /// </summary>
    public class PersonCar : Vehicle {
        /// <summary>
        /// Car constructor
        /// </summary>
        /// <param name="brand">Brand</param>
        /// <param name="model">Model</param>
        /// <param name="km">Distance driven</param>
        /// <param name="year">Production year</param>
        /// <param name="price">Price</param>
        /// <param name="motorSize">Size of motor</param>
        /// <param name="km_l">Travel distance on 1 liter of fuel</param>
        /// <param name="fueltype">Fueltype</param>
        public PersonCar(string brand, string model, int km, DateTime year, int price, double motorSize, double km_l, Fuel fueltype)
            : base(brand, model, km, year, price, motorSize, km_l, fueltype) {
                VehicleType = VehicleTypes.PersonCar;
        }

        #region Properties
        /// <summary>
        /// Max speed of the car
        /// </summary>
        public override int MaxSpeed { get { return 407; } } // Max speed is locked, as per assignment

        /// <summary>
        /// The motor size of the car
        /// </summary>
        public override double MotorSize {
            get { return _MotorSize; }
            set {
                if (!IsMotorSizeOkay(1.0, 4.2, value)) { // Is motorsize okay?
                    throw new ArgumentOutOfRangeException(); // Motorsize not okay
                } else {
                    _MotorSize = value; // Motorsize okay
                }
            }
        }
        private double _MotorSize;
        #endregion

        /// <summary>
        /// Checks if the car is veteran
        /// </summary>
        /// <returns>True if it is a veteran, otherwise false</returns>
        public bool IsVeteran() {
            return (DateTime.Now.Year - Year.Year > 25 ? true : false); // If the car is more than 25 years old, it is a veteran
        }

        /// <summary>
        /// Returns veteran +  title if the car is a veteran
        /// </summary>
        public override string Title {
            get { return (IsVeteran() ? "Veteran " : "") + base.Title; }
        }
    }
}
